<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../css/style.css" />
		<style>
			[v-cloak] {
				display: none;
			}
			
			.mui-btn {
				width: 150px;
				border: 1px solid #25CDDA;
				background-color: #25CDDA;
			}
			
			.mui-btn:active {
				border: 1px solid #58dde8!important;
				background-color: #58dde8!important;
			}
			
			.mui-table-view,
			.bg-img {
				background-image: url(../images/mainBg.jpg);
			}
			
			.mui-table-view-cell {
				height: 35px;
			}
			
			.mui-bar-nav {
				background: #27CDDB;
			}
			.mui-action-back,
			.mui-title,
			.mui-action-back:active {
				color: #FFFFFF;
			}
		</style>
	</head>

	<body class="bg-img">
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title" id="title"></h1>
		</header>
		<div class="mui-content bg-img" id="aicVue" v-cloak>
			<div style="text-align: center;">
				<img v-if="memberMachine.status == 0" src="../images/running.gif" alt="矿机" height="150" width="100%" />
				<img v-if="memberMachine.status != 0" :src="memberMachine.machineImg" alt="矿机" height="150px" width="150px" />
			</div>
			<ul class="mui-table-view">
				<li class="mui-table-view-cell">
					<div>
						<span class="dark-medium">矿机名称:</span>
						<span style="float: right;" class="dark-medium">{{memberMachine.machineName}}</span>
					</div>
				</li>
				<li class="mui-table-view-cell">
					<div>
						<span class="dark-medium">矿机编号:</span>
						<span style="float: right;" class="dark-medium">{{memberMachine.machineNo}}</span>
					</div>
				</li>
				<li class="mui-table-view-cell">
					<div>
						<span class="dark-medium">算力:</span>
						<span style="float: right;" class="dark-medium">{{memberMachine.hashSecond}} GH/S</span>
					</div>
				</li>
				<li class="mui-table-view-cell">
					<div>
						<span class="dark-medium">矿机价格:</span>
						<span style="float: right;" class="dark-medium">{{memberMachine.price}} AIC</span>
					</div>
				</li>
				<li class="mui-table-view-cell">
					<div>
						<span class="dark-medium">总收益:</span>
						<span style="float: right;" class="dark-medium">{{memberMachine.totalProfit}} AIC</span>
					</div>
				</li>
				<li class="mui-table-view-cell">
					<div>
						<span class="dark-medium">运行周期:</span>
						<span style="float: right;" class="dark-medium">{{memberMachine.totalDays}} 天</span>
					</div>
				</li>
				<li class="mui-table-view-cell">
					<div>
						<span class="dark-medium">剩余时间:</span>
						<span style="float: right;" class="dark-medium">{{memberMachine.totalDays-memberMachine.runningDays}} 天</span>
					</div>
				</li>
				<li class="mui-table-view-cell">
					<div>
						<span class="dark-medium">每日收益:</span>
						<span style="float: right;" class="dark-medium">{{memberMachine.dayProfit}} AIC</span>
					</div>
				</li>
				<li class="mui-table-view-cell">
					<div>
						<span class="dark-medium">累计收益:</span>
						<span style="float: right;" class="dark-medium">{{memberMachine.sumProfit}}</span>
					</div>
				</li>
			</ul>
			<div class="mui-button-row">
				<button type="button" class="mui-btn mui-btn-primary" v-if="memberMachine.preProfit" @click="getProfit()">领取{{memberMachine.preProfit}} AIC</button>
			</div>
		</div>

		<script type="text/javascript" src="../js/mui.min.js"></script>
		<script type="text/javascript" src="../js/vue.min.js"></script>
		<script type="text/javascript" src="../js/public.js"></script>
		<script type="text/javascript">
			mui.init();
			var title = document.getElementById("title");
			var vm = new Vue({
				el: '#aicVue',
				data: {
					memberMachine: {}
				},
				mounted: function() {
					mui.plusReady(function() {
						swipeBack();
						vm.memberMachine = plus.webview.currentWebview().item;
						title.innerHTML = vm.memberMachine.machineName;
					});
				},
				methods: {
					getProfit: function() {
						mui.postParam(GetProfit, {
							"mmId": vm.memberMachine.id
						}, function(result) {
							if(result.code == 0) {
								vm.memberMachine.sumProfit = vm.totalSum(vm.memberMachine.sumProfit, vm.memberMachine.preProfit);
								vm.memberMachine.preProfit = 0;
								mui.fire(plus.webview.getWebviewById('kuangchi'), 'setGetProfit', {
									id: vm.memberMachine.id
								});
								mui.fire(plus.webview.getWebviewById('tabmy.html'), 'reLoadData');
								mui.toast("领取成功");
							} else {
								mymui(result.msg);
							}
						});
					},
					totalSum: function(arg1, arg2) {
						var r1, r2, m;
						try {
							r1 = arg1.toString().split(".")[1].length
						} catch(e) {
							r1 = 0
						}
						try {
							r2 = arg2.toString().split(".")[1].length
						} catch(e) {
							r2 = 0
						}
						m = Math.pow(10, Math.max(r1, r2))
						return Number(((arg1 * m + arg2 * m) / m).toFixed(Math.max(r1, r2)));
					}
				}
			});
		</script>
	</body>

</html>